use std::num::ParseIntError;

type AliasedResult<T> = Result<T, ParseIntError>;

fn main() {
    println!("Hello, world!");
    print(multiply("10", "2"));
    print(multiply("t", "2"));
}

fn multiply(f_str: &str, s_str: &str) -> AliasedResult<i32> {
    f_str
        .parse::<i32>()
        .and_then(|fi| s_str.parse::<i32>().map(|sn| fi * sn))
}

fn print(result: Result<i32, ParseIntError>) {
    match result {
        Ok(n) => println!("n is {}", n),
        Err(e) => println!("Error: {}", e),
    }
}
